﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            Text1();
        }

        private static void Text1()
        {
            //1、猫、狗、鸭、猴，（吃、游泳、爬树）
            //所有动物都有吃的方法
            //狗和鸭会游泳，不会爬树
            //猫和猴不会游泳会爬树
            //将吃的方法定义在父类方法中，将游泳和爬树的技能定义为接口
            //所有子类继承父类后，再去继承相应的接口实现技能
            Cat cat = new Cat("猫");
            cat.PrintEat();
            cat.ClimbTree();
            Console.WriteLine("====================");
            Dog dog = new Dog("狗");
            dog.PrintEat();
            dog.Swi();
            Console.WriteLine("====================");
            Ya ya = new Ya("鸭");
            ya.PrintEat();
            ya.Swi();
            Console.WriteLine("====================");
            MonKey monKey = new MonKey("猴");
            monKey.PrintEat();
            monKey.ClimbTree();
        }
    }
    class Animal
    {
        public string _Name;
        public string _Eat;


        public Animal(string eat,string name)
        {
            _Eat = eat;
            _Name = name;
        }
        public Animal() { }

        public virtual void PrintEat() 
        {
            Console.WriteLine("我是{0},我会吃!",_Name);
        }
 

    }
    class Cat : Animal,IClimbTree
    {
        
        public Cat(){}
        public Cat(string name)
        {
            _Name = name;
        }

        

        public override void PrintEat()
        {
           
            base.PrintEat();
        }
        public void ClimbTree()
        {
            Console.WriteLine("我还会爬树");
        }
    }
    class Dog : Animal,ISwimming
    {
       
        public Dog() { }
        public Dog(string name)
        {
            _Name = name;
        }
        public override void PrintEat()
        {
            base.PrintEat();
        }

        public void Swi()
        {
            Console.WriteLine("我还会游泳！");
        }
    }
    class Ya : Animal,ISwimming
    {
        public Ya() { }
        public Ya(string name)
        {
            _Name = name;
        }
        public override void PrintEat()
        {
            base.PrintEat();
        }

        public void Swi()
        {
            Console.WriteLine("我还会游泳！");
        }
    }
    class MonKey : Animal,IClimbTree 
    {

        public MonKey() { }
        public MonKey(string name)
        {
            _Name = name;
        }
        public override void PrintEat()
        {
            base.PrintEat();
        }
        public void ClimbTree()
        {
            Console.WriteLine("我还会爬树");
        }
    }
    

}
